﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace MoveNext.IO.Grf
{
    public class FileEntry : IComparable
    {
        private string fullName;
        private string fileName;
        private string grfDirectory;
        private string fileExtension;
        private int compressedLength;
        private int compressedLengthAlligned;
        private int uncompressedLength;
        private byte flags;
        private int offset;

        public string FullName
        {
            get { return fullName; }
            set
            {
                fullName = value;
                int lastIndex = this.fullName.LastIndexOf('.');
                if (this.fullName.Length - 1 > lastIndex && lastIndex != -1)
                {
                    this.fileExtension = this.fullName.Substring(lastIndex, this.fullName.Length - lastIndex);
                }
                lastIndex = this.fullName.LastIndexOf('\\');
                if (this.fullName.Length - 1 > lastIndex && lastIndex != -1)
                {
                    this.grfDirectory = this.fullName.Substring(0, lastIndex + 1);
                    this.fileName = this.fullName.Substring(lastIndex + 1, this.fullName.Length - lastIndex - 1);
                }
            }
        }
        public string FileName
        {
            get { return fileName; }
            set { fileName = value; }
        }
        public string GrfDirectory
        {
            get { return grfDirectory; }
            set { grfDirectory = value; }
        }
        public string FileExtension
        {
            get { return fileExtension; }
            private set { fileExtension = value; }
        }
        public int CompressedLength
        {
            get { return compressedLength; }
            set { compressedLength = value; }
        }
        public int CompressedLengthAlligned
        {
            get { return compressedLengthAlligned; }
            set { compressedLengthAlligned = value; }
        }
        public int UncompressedLength
        {
            get { return uncompressedLength; }
            set { uncompressedLength = value; }
        }
        public byte Flags
        {
            get { return flags; }
            set { flags = value; }
        }
        public int Offset
        {
            get { return offset; }
            set { offset = value; }
        }

        #region IComparable Members

        public int CompareTo(object obj)
        {
            return this.fileName.CompareTo(((FileEntry)obj).fileName);
        }

        #endregion
    }
}
